package org.desktop.web.shared.domain.entities;

import java.io.Serializable;

import javax.persistence.*;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;


/**
 * The persistent class for the CUSTOMERS_ENABLED database table.
 * 
 */
@Entity
@Table(name="CUSTOMERS_ENABLED")
@NamedQuery(name="CustomersEnabled.findAll", query="SELECT c FROM CustomersEnabled c")
@JsonAutoDetect(fieldVisibility=Visibility.ANY)
@JsonIgnoreProperties(value="users")
@JsonInclude(Include.NON_NULL)
public class CustomersEnabled implements Serializable, com.google.gwt.user.client.rpc.IsSerializable {
	private static final long serialVersionUID = 1L;
	private int id;
	private String customerDesc;
	private String customerKey;
	private List<User> users;

	public CustomersEnabled() {
	}


	@Id
	@Column(unique=true, nullable=false)
	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}


	@Column(name="CUSTOMER_DESC", length=45)
	public String getCustomerDesc() {
		return this.customerDesc;
	}

	public void setCustomerDesc(String customerDesc) {
		this.customerDesc = customerDesc;
	}


	@Column(name="CUSTOMER_KEY", length=100)
	public String getCustomerKey() {
		return this.customerKey;
	}

	public void setCustomerKey(String customerKey) {
		this.customerKey = customerKey;
	}


	//bi-directional many-to-one association to User
	@OneToMany(mappedBy="customersEnabled")
	public List<User> getUsers() {
		return this.users;
	}

	public void setUsers(List<User> users) {
		this.users = users;
	}

	public User addUser(User user) {
		getUsers().add(user);
		user.setCustomersEnabled(this);

		return user;
	}

	public User removeUser(User user) {
		getUsers().remove(user);
		user.setCustomersEnabled(null);

		return user;
	}

}